<script type="text/javascript">
	function GoToIndex() {
		//Create URL
		var url = "<?php echo $this->createURL("", array("id"=>"xreplacex"))?>";
		url = url.replace("xreplacex",document.getElementById("divisi").selectedIndex);

		//Go
		window.location = url;
	}

	function updateNilai(id) {
		//Regex first
		
		
		//Create url
		var m_Url = "<?php echo $this->createURL("update", array("id"=>"xidx","divisi"=>"xdivisix","nilai"=>"xnilaix"))?>";
		m_Url = m_Url.replace("xidx",id);
		m_Url = m_Url.replace("xdivisix",document.getElementById("divisi").selectedIndex+1);
		m_Url = m_Url.replace("xnilaix",document.getElementById("nilai-" + id).value);

		//Send ajax request
		$.ajax({
			   type: "POST",
			   url: m_Url,
			   success: function(msg){
			     alert(msg);
			   }
		});

	}
</script>

<?php
$this->breadcrumbs=array(
	'SIPMA'=>array($this->createUrl('/../sipma')),
	'Planning',
);
?>

<h1>Planning</h1>

<p>
	Division : 
	<?php 
		echo CHtml::dropDownList('divisi', $id, $division);
		echo CHtml::submitButton('Go', array('onClick'=>'GoToIndex()'));
	?>
</p>

<div>
	<div class="information"> Total Pagu Operasi Pos 53 : </div>
	
	<br/>
	
	
	<div class="form">
		<?php 
			echo CHtml::form('', 'post', array('enctype'=>'multipart/form-data')); 
			echo CHtml::activeLabel($model53,'Upload Excel File Here : ');
			echo CHtml::activeFileField($model53, 'document');
		?>
		
		<br/>
		
		<?php 
			echo CHtml::submitButton('Upload'); 
			echo CHtml::endForm();
		?>
	</div>
	
	<br/>
	
	<div class="information"> Total Pagu Operasi Pos 54 : </div>
	
	<div class="form">
	<?php 
		$this->widget('zii.widgets.grid.CGridView', array(
			'id'=>'form-54',
			'dataProvider'=>$model54->searchPos54($id+1),
			'filter'=>$model54,
			'columns'=>array(
		 		array(
	                'header'=>'No.',
	                'value'=>'$this->grid->dataProvider->pagination->currentPage*$this->grid->dataProvider->pagination->pageSize + $row+1',
        		),
        		array(
        			'name'=>'jenis_pos',
        			'filter'=>false,
        		),
				'jenis_subpos',
				'keterangan',
        		array(
        			'name'=>'poses.pagus.nilai_rupiah',
        			'value'=> 'CHtml::textField($data->id,$data->poses->pagus->nilai_rupiah,array(
        					"onChange"=>"updateNilai($data->id);",
        					"id"=>"nilai-$data->id"))',
        			'type' => 'raw',
        		),
			),
		)); 
	?>
	</div>
</div>